X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/097781e6ad3f7bb1c13c16ff7b6bb7219764fb29..b587e9d8e0cc5eb1edf972fd3b644704441e5289:/Super%20Polarity/ActorManager.cs?ds=sidebyside diff --git a/Super Polarity/ActorManager.cs b/Super Polarity/ActorManager.cs index 8cd265a..f5587b9 100644 --- a/Super Polarity/ActorManager.cs +++ b/Super Polarity/ActorManager.cs @@ -27,7 +27,9 @@ namespace SuperPolarity static public void CheckOut(Actor actor) { + actor.CleanUp(); Actors.Remove(actor); + actor = null; } static public void Update(GameTime gameTime) @@ -55,6 +57,12 @@ namespace SuperPolarity if (i >= Actors.Count) { i = Actors.Count - 1; } + + if (Actors.Count == 0) + { + return; + } + Actor actor = Actors[i]; for (var j = i - 1; j >= 0; j--) { @@ -110,13 +118,43 @@ namespace SuperPolarity actor.Position.Y > Game.GraphicsDevice.Viewport.Height + OutlierBounds) { CheckOut(actor); + if (actor.Parent != null) + { + actor.Parent.Children.Remove(actor); + } } } } + static public void Empty() + { + foreach (Actor actor in Actors) { + actor.CleanUp(); + } + Actors.Clear(); + } + internal static void SetGame(SuperPolarity game) { Game = game; } + + public static void Bomb() + { + for (var i = Actors.Count - 1; i >= 0; i--) + { + var actor = Actors[i]; + if (actor.GetType() == typeof(StandardShip)) + { + CheckOut(actor); + Renderer.CheckOut(actor); + } + } + } + + public static int CountBaddies() + { + return Actors.Where(a => a.GetType() == typeof(StandardShip)).Count(); + } } }